﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace TaskBooker.Windows
{
    /// <summary>
    /// Interaction logic for GlassWindow.xaml
    /// </summary>
    public partial class GlassWindow : Window
    {
        public GlassWindow()
        {
            InitializeComponent();
        }

        [StructLayout( LayoutKind.Sequential )]
        private struct MARGINS
        {
            public int cxLeftWidth;      // width of left border that retains its size
            public int cxRightWidth;     // width of right border that retains its size
            public int cyTopHeight;      // height of top border that retains its size
            public int cyBottomHeight;   // height of bottom border that retains its size
        };

        [DllImport( "dwmapi.dll" )]
        private static extern int DwmExtendFrameIntoClientArea( IntPtr hwnd, ref MARGINS pMarInset );

        private void Window_Loaded( object sender, RoutedEventArgs e )
        {
            WindowInteropHelper windowInteropHelper = new WindowInteropHelper( this );
            IntPtr myHwnd = windowInteropHelper.Handle;
            HwndSource mainWindowSrc = System.Windows.Interop.HwndSource.FromHwnd( myHwnd );
            
            mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb( 0, 0, 0, 0 );

            MARGINS margins = new MARGINS()
            {
                cxLeftWidth = -1,
                cxRightWidth = -1,
                cyBottomHeight = -1,
                cyTopHeight = -1
            };

            DwmExtendFrameIntoClientArea( myHwnd, ref margins );
        }
    }
}
